<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.创建一个Star类
        class Star {
            // 类中的构造函数
            constructor(uname) { 
                this.uname = uname
                //对象私有方法
                this.say = ()=>{
                    console.log(this.uname+'会说话');
                }
            }
            // 对象共有方法
            sing(){
                console.log('明星会唱歌');
            }
        }

        // 2.实例化对象
        let ldh =  new Star('刘德华')
        console.log(ldh.uname);
        ldh.say()
        ldh.sing()
    </script>
</body>

</html>